package lab03.test01;


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Test01 {
    public static void main(String[] args) {
        String path = "D:\\hello.txt";
        /**
         * 1.字符流
         *    一次读一行
         * 2.字节流
         */
        BufferedReader reader = null;
        try {

            reader = new BufferedReader(new FileReader(path));
            String line = "";//保存读一行的数据

            while((line = reader.readLine())!=null){

                //line = reader.readLine();
                System.out.println(line);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                reader.close();//打开文件后，需要关闭文件,一定要关闭。
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        //2.字节流
    }
}
